﻿/**
* Key.js
* 
* @author Demis Bellot
* @version 1.0
*
* Copyright 2009, Demis Bellot
* http://code.google.com/p/ajaxstack/
*/

function Key() { }
Key.isRenameKey = function(key) { return key == Key.f2 || key == Key.enter; };
Key.isEnterKey = function(key) { return key == Key.enter; };
Key.isEscapeKey = function(key) { return key == Key.escape; };
Key.isSpaceKey = function(key) { return key == Key.space; };
Key.isUpKey = function(key) { return key == Key.up; };
Key.isDownKey = function(key) { return key == Key.down; };
Key.isDeleteKey = function(key) { return key == Key.$delete; };
Key.escape = 27;
Key.f2 = 113;
Key.enter = 13;
Key.space = 32;
Key.left = 37;
Key.up = 38;
Key.right = 39;
Key.down = 40;
Key.$delete = 46;

Key.processKey = function(key, onEnterFn, onCancelFn)
{
	if (Key.isRenameKey(key))
	{
		onEnterFn();
		return false;
	}
	else if (Key.isEscapeKey(key))
	{
		onCancelFn();
		return false;
	}
	return true;
};

